package com.benjaminwan.read.free.ui.compatibility

import android.content.Context
import com.airbnb.mvrx.MvRxViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import com.benjaminwan.read.free.base.viewmodel.MvRxViewModel

class CompatViewModel(
    initialState: CompatState,
    val context: Context
) : MvRxViewModel<CompatState>(initialState) {

    fun setCompat(isCompat: Boolean) {
        setState { copy(isCompat = isCompat) }
    }

    companion object : MvRxViewModelFactory<CompatViewModel, CompatState> {
        override fun create(
            viewModelContext: ViewModelContext,
            state: CompatState
        ): CompatViewModel? {
            val context = viewModelContext.activity.applicationContext
            return CompatViewModel(state, context)
        }
    }
}